package edu.sctu.zcy.month201505.subwaysystem.V2;

import java.util.HashMap;

/**
 * Created by wswk on 2015/6/1.
 */
public class DeductionsRules {


    public int getCountStation(String startStation,String endStation){

        HashMap<String,Integer> setStation = new SetStation().setStation();
        int count = 0;
        if (setStation.get(startStation) > setStation.get(endStation)){

            count = setStation.get(startStation) - setStation.get(endStation);
        } else {
            count = setStation.get(endStation) - setStation.get(startStation);
        }
        return count;
    }

    public int getPrice(Passenger passenger){

        int price = 2;

            if (getCountStation(passenger.getStartStation(), passenger.getEndStation()) < 3) {

                price = 2;

            } else if (getCountStation(passenger.getStartStation(), passenger.getEndStation()) >= 3 &&

                    getCountStation(passenger.getStartStation(), passenger.getEndStation()) < 6) {
                price = 4;
            } else if (getCountStation(passenger.getStartStation(), passenger.getEndStation()) >= 6 &&

                    getCountStation(passenger.getStartStation(), passenger.getEndStation()) < 8) {
                price = 5;
            } else {
                price = 6;
            }


        return price;
    }


    public void setRecharge(int money,Passenger passenger){
        passenger.setCardBalance(money + passenger.getCardBalance());
    }



}
